/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Berekenen.Calc;
import Domain.MateriaalSoort;
import Domain.Prepreg;
import Draw.ColorSet;
import Exceptions.BelowOrEqualsToZeroException;
import Exceptions.NoNameGivenException;
import Delta.Lamel;
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import laminaatapplicatie.Global;

/**
 *
 * @author Memet
 */
public class EditPrepeg extends javax.swing.JFrame {
    private Color fiberColor;
    private Color epoxyColor;
    private MateriaalSoort soort;
    //private Prepreg m;
    private Lamel lamel;
    /**
     * Creates new form EditPrepeg
     */
    public EditPrepeg() {
        initComponents();
        fiberColor = Color.red;
        epoxyColor = Color.WHITE;
        soort = MateriaalSoort.UNIDIRECTIONAAL;
        lamel = null;
    }

    public void setMaterial(Lamel lamel)
    {
        this.lamel = lamel;
        fiberColor = lamel.getColorSet().getFiber();
        epoxyColor = lamel.getColorSet().getBackground();
        soort = lamel.getType();
        txtDiktePre.setText(String.valueOf(lamel.getThickness()));
        txtEl.setText(String.valueOf(Calc.Round(lamel.getEl()/1e9, 2)));
        txtEt.setText(String.valueOf(Calc.Round(lamel.getEt()/1e9, 2)));
        txtGlt.setText(String.valueOf(Calc.Round(lamel.getGlt()/1e9, 2)));
        txtA1.setText(String.valueOf(Calc.Round(lamel.getAlphaL(), 2)));
        txtA2.setText(String.valueOf(Calc.Round(lamel.getAlphaT(), 2)));
        txtNult.setText(String.valueOf(Calc.Round(lamel.getMult(), 2)));
        txtFabrikantPre.setText(lamel.getManufacturer());
        txtNaamPre.setText(lamel.getName());
        txtRho.setText(String.valueOf(Calc.Round(lamel.getRhol(), 2)));
        cbTypePre.setSelectedIndex(2);
        if(lamel.getType().equals(MateriaalSoort.UNIDIRECTIONAAL))
        {
            cbTypePre.setSelectedIndex(0);
        }
        else if(lamel.getType().equals(MateriaalSoort.MINVIJFENVEERTIGVIJFENVEERTIG))
        {
            cbTypePre.setSelectedIndex(1);
        }
        updateForm();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        cbTypePre = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        txtDiktePre = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtNaamPre = new javax.swing.JTextField();
        txtFabrikantPre = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        btnEditMaterialPre = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        examp1 = new Draw.pnlExample();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        btnFiberColorPre = new javax.swing.JButton();
        btnEpoxyColorPre = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        txtEl = new javax.swing.JTextField();
        txtEt = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtNult = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        txtRho = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtGlt = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        txtA1 = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        txtA2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        cbTypePre.setFont(new java.awt.Font("Rockwell", 1, 11)); // NOI18N
        cbTypePre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UD", "-45° / + 45°", "0° / 90°" }));
        cbTypePre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTypePreActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Thickness [mm]");

        txtDiktePre.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtDiktePre.setText("1");

        jLabel8.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("Name");

        txtNaamPre.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtNaamPre.setText("Material01");

        txtFabrikantPre.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jLabel9.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Manufacturer");

        btnEditMaterialPre.setFont(new java.awt.Font("Rockwell", 1, 11)); // NOI18N
        btnEditMaterialPre.setText("Edit Material");
        btnEditMaterialPre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditMaterialPreActionPerformed(evt);
            }
        });

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        examp1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 153, 0), 1, true));

        javax.swing.GroupLayout examp1Layout = new javax.swing.GroupLayout(examp1);
        examp1.setLayout(examp1Layout);
        examp1Layout.setHorizontalGroup(
            examp1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 48, Short.MAX_VALUE)
        );
        examp1Layout.setVerticalGroup(
            examp1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 18, Short.MAX_VALUE)
        );

        jLabel10.setText("Fiber plot color");

        jLabel11.setText("Epoxy plot color");

        btnFiberColorPre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFiberColorPreActionPerformed(evt);
            }
        });

        btnEpoxyColorPre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEpoxyColorPreActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(75, 75, 75)
                        .addComponent(examp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel11))
                        .addGap(72, 72, 72)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnFiberColorPre, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnEpoxyColorPre, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(examp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addComponent(jLabel10))
                    .addComponent(btnFiberColorPre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel11)
                    .addComponent(btnEpoxyColorPre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(68, 68, 68))
        );

        jLabel12.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("El [GPa]");

        txtEl.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtEl.setText("0");

        txtEt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtEt.setText("0");

        jLabel13.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("Et [GPa]");

        txtNult.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtNult.setText("0");

        jLabel14.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("vlt");

        txtRho.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtRho.setText("0");
        txtRho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRhoActionPerformed(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("[Kg/m3]");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("ρ");

        jLabel17.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel17.setText("Glt [GPa]");

        txtGlt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtGlt.setText("0");

        jLabel18.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel18.setText("<html>αl [°C<sup>-1</sup>]</html>");

        txtA1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtA1.setText("0");

        jLabel19.setFont(new java.awt.Font("Trebuchet MS", 1, 11)); // NOI18N
        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setText("<html>αt [°C<sup>-1</sup>]</html>");

        txtA2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtA2.setText("0");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtEl)
                            .addComponent(jLabel12))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtEt)
                            .addComponent(jLabel13))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtNult, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtGlt)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtA1)
                            .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtA2)
                            .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnEditMaterialPre, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbTypePre, 0, 108, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                            .addComponent(txtDiktePre, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addComponent(txtNaamPre, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addComponent(txtFabrikantPre, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE))
                .addGap(95, 95, 95))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtRho, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel15)
                        .addGap(14, 14, 14)))
                .addContainerGap(310, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel14)
                            .addGap(5, 5, 5)
                            .addComponent(txtNult, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel17)
                            .addGap(5, 5, 5)
                            .addComponent(txtGlt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel13)
                            .addGap(5, 5, 5)
                            .addComponent(txtEt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(5, 5, 5)
                        .addComponent(txtEl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(5, 5, 5)
                        .addComponent(txtA1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(5, 5, 5)
                        .addComponent(txtA2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel15))
                .addGap(5, 5, 5)
                .addComponent(txtRho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(cbTypePre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDiktePre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addGap(8, 8, 8)
                .addComponent(txtNaamPre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtFabrikantPre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEditMaterialPre)
                .addGap(44, 44, 44))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbTypePreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTypePreActionPerformed
        soort = MateriaalSoort.NULNEGENTIG;

        if (cbTypePre.getSelectedIndex() == 0) {
            soort = MateriaalSoort.UNIDIRECTIONAAL;

        } else if (cbTypePre.getSelectedIndex() == 1) {
            soort = MateriaalSoort.MINVIJFENVEERTIGVIJFENVEERTIG;

        }
        updateForm();
    }//GEN-LAST:event_cbTypePreActionPerformed

    private void btnEditMaterialPreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditMaterialPreActionPerformed
        try {
            soort = MateriaalSoort.NULNEGENTIG;
            if (cbTypePre.getSelectedIndex() == 0) {
                soort = MateriaalSoort.UNIDIRECTIONAAL;
            } else if (cbTypePre.getSelectedIndex() == 1) {
                soort = MateriaalSoort.MINVIJFENVEERTIGVIJFENVEERTIG;
            }
            if (txtNaamPre.getText().equalsIgnoreCase("")) {
                throw new NoNameGivenException();
            }
            System.out.println(cbTypePre.getSelectedIndex());
            double el = Double.parseDouble(txtEl.getText()) * 1e9;
            double et = Double.parseDouble(txtEt.getText()) * 1e9;
            double nult = Double.parseDouble(txtNult.getText());
            double glt = Double.parseDouble(txtGlt.getText()) * 1e9;
            double rho = Double.parseDouble(txtRho.getText());
            double dikte = Double.parseDouble(txtDiktePre.getText());
            double a1 = Double.parseDouble(txtA1.getText());
            double a2 = Double.parseDouble(txtA2.getText());
            //Prepreg newMat = new Prepreg(txtNaamPre.getText(), el, et, nult, glt, rho, a1, a2, soort, dikte, new ColorSet(epoxyColor, fiberColor));
            //newMat.setFabrikant(txtFabrikantPre.getText());
            //Global.data.setMateriaal(m, newMat);
            Lamel newMat = new Lamel(txtNaamPre.getText(), el, et, nult, glt, rho, a1, a2, /*soort,*/ dikte, new ColorSet(epoxyColor, fiberColor));
            newMat.setManufacturer(txtFabrikantPre.getText());
            Global.data.setLamel(lamel, newMat);

        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, "One of the entered values is not valid");
        } catch (BelowOrEqualsToZeroException ex) {
            JOptionPane.showMessageDialog(rootPane, "The thickness of the material has to be higher than 0");
        } catch (NoNameGivenException ex) {
            JOptionPane.showMessageDialog(rootPane, "Please enter a name for the material");
        }
        if (txtNaamPre.getText().equals("Material" + Global.data.geefNieuweMaterialNaam())) {
            Global.data.gebruikNieuweMaterialNaam();
        }
        Global.menu.editMaterialButton(true);
        Global.menu.refreshScreens();
        this.dispose();
    }//GEN-LAST:event_btnEditMaterialPreActionPerformed

    private void btnFiberColorPreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFiberColorPreActionPerformed
        JColorChooser cc = new JColorChooser();
        cc.setPreviewPanel(new JPanel());
        cc.repaint();
        Color kleurtje = cc.showDialog(rootPane, "Choose a plot color", Color.red);
        if (kleurtje != null) {
            fiberColor = kleurtje;
        }

        updateForm();
    }//GEN-LAST:event_btnFiberColorPreActionPerformed

    private void btnEpoxyColorPreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEpoxyColorPreActionPerformed
        JColorChooser cc = new JColorChooser();
        cc.setPreviewPanel(new JPanel());
        cc.repaint();
        Color kleurtje = cc.showDialog(rootPane, "Choose a plot color", Color.red);
        if (kleurtje != null) {
            epoxyColor = kleurtje;
        }

        updateForm();
    }//GEN-LAST:event_btnEpoxyColorPreActionPerformed

    private void txtRhoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtRhoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtRhoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EditPrepeg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EditPrepeg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EditPrepeg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EditPrepeg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new EditPrepeg().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnEditMaterialPre;
    private javax.swing.JButton btnEpoxyColorPre;
    private javax.swing.JButton btnFiberColorPre;
    private javax.swing.JComboBox cbTypePre;
    private Draw.pnlExample examp1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTextField txtA1;
    private javax.swing.JTextField txtA2;
    private javax.swing.JTextField txtDiktePre;
    private javax.swing.JTextField txtEl;
    private javax.swing.JTextField txtEt;
    private javax.swing.JTextField txtFabrikantPre;
    private javax.swing.JTextField txtGlt;
    private javax.swing.JTextField txtNaamPre;
    private javax.swing.JTextField txtNult;
    private javax.swing.JTextField txtRho;
    // End of variables declaration//GEN-END:variables
    private void updateForm() {
         btnEpoxyColorPre.setBackground(epoxyColor);
        btnFiberColorPre.setBackground(fiberColor);
        examp1.setSet(new ColorSet(epoxyColor, fiberColor));

        examp1.setSoort(soort);
        examp1.setTheta(0);

        examp1.repaint();
        this.validate();
        this.repaint();
    }
}
